package com.wbu.mapper;

import java.util.Date;
import java.util.List;

import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import com.wbu.entity.Admin;
@Mapper
public interface AdminMapper {
	
	@Select("select * from admin where name=#{name} and password = #{password} ")
	public List<Admin> login(Admin admin); 
	
	@Select("select * from admin")
	public List<Admin> findAll(); 
	
	@Select("select * from admin where id =  #{id}")
	public Admin findById(@Param("id") int id);
	
	@Select("select * from admin where name like concat(concat(\"%\",#{name}),\"%\") ")
	public List<Admin> findByName(@Param("name") String name);
	
	@Insert("insert into admin(name,password,createDate) values(#{name},#{password},SYSDATE())")
	public int insert(Admin admin);
	
	@Update("update admin set name = #{name} ,password = #{password} where id = #{id}")
	public int update(Admin admin);
	
	@Delete("delete from admin where id = #{id}")
	public int delete(int id);
}
